/**
*
* TaskName : GoogleSearch
* Purpose : test
* Entry Points : test
* Exit Points : test
* Inputs :
* Outputs :
* Tables : 
* Complete : 
* Comments : 
*/

package com.ibm.commerce.url.tasks.mls;

import com.ibm.commerce.url.harness.*;
import com.ibm.commerce.url.util.Log;
import com.ibm.commerce.url.exception.*;
import com.ibm.wc.test.exception.DatablockMissingException;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.LinkedHashMap;
import java.util.Map;

public class GoogleSearch extends URLTestTask {
	
	public static final String INPUT_PARAMETER_NAME_Q = "q";

	private static GoogleSearch instance = new GoogleSearch();
	private GoogleSearch(){}

	public static void execute() throws TaskFailException, DatablockMissingException {
		instance.runTask();
	}

	public static void execute(int counterIndex) throws TaskFailException, DatablockMissingException {
		instance.runTask(counterIndex);
	}

	public void executeTask() throws TaskFailException {
		GoogleSearchStep1_search();
	}

	private static Map<String, String> GoogleSearchStep1_search_FORM = new LinkedHashMap<String, String>();
	static{ 
		GoogleSearchStep1_search_FORM.put("q" , "%E6%B1%89%E5%AD%97");
		GoogleSearchStep1_search_FORM.put("hl" , "zh-CN");
		GoogleSearchStep1_search_FORM.put("btnG" , "Google+%E6%90%9C%E7%B4%A2");
		GoogleSearchStep1_search_FORM.put("source" , "hp");
	}

	public void GoogleSearchStep1_search() throws TaskFailException {
		Log.finest("Task["+this.getClass().getSimpleName()+"]: Entering GoogleSearchStep1_search");
		

		try {
		//	putParameterInMap(GoogleSearchStep1_search_FORM, "q", URLDecoder.decode("%E6%B1%89%E5%AD%97","UTF-8"));
			putParameterInMap(GoogleSearchStep1_search_FORM, "q", getParameterFromDataFile(INPUT_PARAMETER_NAME_Q));
			putParameterInMap(GoogleSearchStep1_search_FORM, "btnG", URLDecoder.decode("Google+%E6%90%9C%E7%B4%A2","UTF-8"));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			Log.severe(e.getMessage());
			e.printStackTrace();
		}

		WebHit("http://www.google.cn/search" , WEB_FORM_GET , GoogleSearchStep1_search_FORM);

		Log.finest("Task["+this.getClass().getSimpleName()+"]: Exiting GoogleSearchStep1_search");
	}


}
